package com.tuozixuan.tomj;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.tomlj.Toml;
import org.tomlj.TomlArray;
import org.tomlj.TomlParseResult;
import org.tomlj.TomlTable;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args ) throws IOException
    {
        System.out.println( "Hello World!" );
        
        Path source = Paths.get("D:\\system\\workspace-demo\\demo\\tomj-demo\\src\\main\\resources/file.toml");
        TomlParseResult result = Toml.parse(source);
        result.errors().forEach(error -> System.err.println(error.toString()));

        String value = result.getString("1234");
        System.out.println(value);
        
        TomlTable appleTable = result.getTable("apple");
        System.out.println(appleTable.get("type"));
        
        Long int1 = result.getLong("int1");
        System.out.println(int1);
        
        Boolean bool1 = result.getBoolean("bool2");
        System.out.println(bool1);
        
        TomlArray array = result.getArray("integers");
        System.out.println(array.getLong(0));
    }
}
